import { AcupointConfig } from "../../../resource/AcupointConfig";
import { Language } from "../../../../../extend/language/Language";
import { SAcupointAttributes } from "../../../../../Message/Game/SAcupointAttributes";
import { ClockManager } from "../../../manager/ClockManager";
import { Global } from "../../../../../com/gengine/global/Global";
import { SAcupointInfo } from "../../../../../Message/Game/SAcupointInfo";
import { SSavvyRate } from "../../../../../Message/Game/SSavvyRate";
import { SecTimer } from "../../../../../com/gengine/core/frame/SecTimer";
import { TimerType } from "../../../../../com/gengine/core/frame/TimerType";
import { SecondCareerUtil } from "../../secondCareer/util/SecondCareerUtil";
import { EEntityAttribute } from "../../../../../Message/Public/EEntityAttribute";
type int = number;
//class AcupointData
    
    export  class AcupointData
    {
        

        public static getRootEffects(arg1: int): int
        {
            var loc1=AcupointData.acupointInfo.rootEffects;
            return loc1[arg1];
        }

        public static setRootEffects(arg1: int, arg2: int): void
        {
            var loc1=AcupointData.acupointInfo.rootEffects;
            loc1[arg1] = arg2;
            return;
        }

        public static getTotalTime(): void
        {
            var loc1=AcupointData.acupointInfo.step;
            var loc2=AcupointData.getSavvyLevel(loc1);
            var loc3=AcupointConfig.instance.getSavvyInfoByTarget(loc2);
            var loc4=loc3.addper;
            var loc5=AcupointData.getAcupointCurLevel(AcupointData.acupointInfo.step, AcupointData.acupointInfo);
            var loc6;
            var loc7=(loc6 = AcupointConfig.instance.getAcupointInfo(loc5, loc1)).time;
            AcupointData.totalTime = loc7 * (1 - loc4 / 10000);
            return;
        }

        public static getNeedAcupoint(arg1: int, arg2: int): string
        {
            var loc1="";
            if (arg1 >= 2 && arg1 <= 8) 
            {
                loc1 = loc1 + AcupointData.getAcupointName((arg1 - 1)) + (arg2 + 1) + Language.getString(30125);
            }
            else if (arg1 == 1) 
            {
                loc1 = loc1 + Language.getString(30123) + arg2 + Language.getString(30125);
            }
            return loc1;
        }

        public static getAttributesByStep(arg1: int, arg2: int, arg3: Map<any, any> /* flash.utils.Dictionary */): Array<any>
        {
            var loc3=null;
            var loc1;
            var loc2;
            if ((loc2 = (loc1 = arg3)[arg1]) == null) 
            {
                return [];
            }
            var loc4=arg2;
            switch (loc4) 
            {
                case 1:
                {
                    loc3 = loc2.addNow;
                    break;
                }
                case 2:
                {
                    loc3 = loc2.addNext;
                    break;
                }
                case 3:
                {
                    loc3 = loc2.addNextRoot;
                    break;
                }
            }
            return loc3;
        }

        public static setAttributesByStep(arg1: int, arg2: SAcupointAttributes): void
        {
            var loc1=AcupointData.acupointInfo.attributes;
            loc1[arg1] = arg2;
            return;
        }

        public static getRootBreakThroughsLevelByStep(arg1: int): int
        {
            var loc1=0;
            var loc2=AcupointData.acupointInfo.rootBreakThroughs;
            if (loc2) 
            {
                loc1 = loc2[arg1];
            }
            if (loc1 == 0) 
            {
                loc1 = 100;
            }
            return loc1;
        }

        public static isRootBreakThroughOpen(): Boolean
        {
            var loc1=false;
            var loc2=ClockManager.instance.nowDate;
            var loc3=new Date(2012, 7, 22);
            if (Global.isDebugModle || loc2.time >= loc3.time) 
            {
                loc1 = true;
            }
            return loc1;
        }

        
        {
            AcupointData.topLevel = 28;
            AcupointData.selectedStep = 1;
            AcupointData.maxRoot = 130;
        }

        public static setInfo(arg1: SAcupointInfo): void
        {
            AcupointData.acupointInfo = arg1;
            AcupointData.leftTime = arg1.leftTime;
            return;
        }

        public static setSavvyRate(arg1: SSavvyRate): void
        {
            AcupointData.savvyRate = arg1;
            return;
        }

        public static get curSavvyRate(): SSavvyRate
        {
            return AcupointData.savvyRate;
        }

        public static get curTotalTime(): number
        {
            return AcupointData.totalTime;
        }

        public static get isUpgrading(): Boolean
        {
            return AcupointData.secTimer && AcupointData.secTimer.running;
        }

        public static setSecTimer(arg1: int): void
        {
            AcupointData.getTotalTime();
            if (arg1 > AcupointData.totalTime) 
            {
                AcupointData.totalTime = arg1;
            }
            AcupointData.leftTime = arg1;
            if (AcupointData.secTimer == null) 
            {
                AcupointData.secTimer = new SecTimer();
                AcupointData.secTimer.addListener(TimerType.ENTERFRAME, AcupointData.onTimerEnterFrameHandler);
                AcupointData.secTimer.addListener(TimerType.COMPLETE, AcupointData.onTimerCompleteHandler);
            }
            AcupointData.secTimer.stop();
            AcupointData.secTimer.reset();
            AcupointData.secTimer.delay = 1;
            AcupointData.secTimer.repeatCount = arg1;
            AcupointData.secTimer.start();
            return;
        }

        /* internal  */static onTimerEnterFrameHandler(arg1: SecTimer): void
        {
            AcupointData.leftTime = arg1.repeatCount;
            return;
        }

        /* internal  */static onTimerCompleteHandler(arg1: SecTimer): void
        {
            arg1.stop();
            arg1.isDelete = false;
            AcupointData.leftTime = 0;
            return;
        }

        public static get leftTimes(): int
        {
            return AcupointData.leftTime;
        }

        public static getAcupointName(arg1: int): string
        {
            var loc1="";
            var loc2=arg1;
            switch (loc2) 
            {
                case 1:
                {
                    loc1 = Language.getString(30116);
                    break;
                }
                case 2:
                {
                    loc1 = Language.getString(30117);
                    break;
                }
                case 3:
                {
                    loc1 = Language.getString(30118);
                    break;
                }
                case 4:
                {
                    loc1 = Language.getString(30119);
                    break;
                }
                case 5:
                {
                    loc1 = Language.getString(30120);
                    break;
                }
                case 6:
                {
                    loc1 = Language.getString(30121);
                    break;
                }
                case 7:
                {
                    loc1 = Language.getString(30122);
                    break;
                }
                case 8:
                {
                    loc1 = Language.getString(30123);
                    break;
                }
            }
            return loc1;
        }

        public static getAttributeStr(arg1: Array<any>, arg2: string, arg3: int, arg4: int, arg5: Boolean=true, arg6: Boolean=true): string
        {
            var loc1=0;
            var loc2=null;
            var loc3=0;
            arg2 = arg2;
            loc1 = 0;
            while (loc1 < arg1.length) 
            {
                if (loc1 > 0 && !arg6) 
                {
                    break;
                }
                loc2 = arg1[loc1];
                if ((loc3 = SecondCareerUtil.getSecondAttribute(loc2.attribute.__value, arg3, arg4)) != EEntityAttribute._EAttributeMaxLife) 
                {
                    if (loc3 != EEntityAttribute._EAttributeMaxMana) 
                    {
                        if (loc3 != EEntityAttribute._EAttributePhysicalDefense) 
                        {
                            if (loc3 != EEntityAttribute._EAttributeMagicDefense) 
                            {
                                if (loc3 != EEntityAttribute._EAttributeHit) 
                                {
                                    if (loc3 != EEntityAttribute._EAttributeJouk) 
                                    {
                                        if (loc3 != EEntityAttribute._EAttributeToughness) 
                                        {
                                            if (loc3 != EEntityAttribute._EAttributePhysicalCrit) 
                                            {
                                                if (loc3 != EEntityAttribute._EAttributeMagicCrit) 
                                                {
                                                    if (loc3 != EEntityAttribute._EAttributePhysicalAttack) 
                                                    {
                                                        if (loc3 == EEntityAttribute._EAttributeMagicAttack) 
                                                        {
                                                            arg2 = arg2.concat(Language.getString(30163));
                                                        }
                                                    }
                                                    else 
                                                    {
                                                        arg2 = arg2.concat(Language.getString(30162));
                                                    }
                                                }
                                                else 
                                                {
                                                    arg2 = arg2.concat(Language.getString(30161));
                                                }
                                            }
                                            else 
                                            {
                                                arg2 = arg2.concat(Language.getString(30160));
                                            }
                                        }
                                        else 
                                        {
                                            arg2 = arg2.concat(Language.getString(30159));
                                        }
                                    }
                                    else 
                                    {
                                        arg2 = arg2.concat(Language.getString(30158));
                                    }
                                }
                                else 
                                {
                                    arg2 = arg2.concat(Language.getString(30157));
                                }
                            }
                            else 
                            {
                                arg2 = arg2.concat(Language.getString(30156));
                            }
                        }
                        else 
                        {
                            arg2 = arg2.concat(Language.getString(30155));
                        }
                    }
                    else 
                    {
                        arg2 = arg2.concat(Language.getString(30026));
                    }
                }
                else 
                {
                    arg2 = arg2.concat(Language.getString(30025));
                }
                if (arg5) 
                {
                    if (arg6) 
                    {
                        if (loc1 == (arg1.length - 1)) 
                        {
                            arg2 = arg2.concat(" +" + loc2.value + "\n");
                        }
                        else 
                        {
                            arg2 = arg2.concat(" +" + loc2.value + "\n");
                        }
                    }
                    else 
                    {
                        arg2 = arg2.concat(" +" + loc2.value + " ");
                    }
                }
                ++loc1;
            }
            return arg2;
        }

        public static getAcupointCurLevel(arg1: int, arg2: SAcupointInfo): int
        {
            var loc1=arg2.acupoint;
            if (arg2.step > 1 && arg2.step <= arg1) 
            {
                --loc1;
            }
            return loc1;
        }

        public static getRootLevel(arg1: int): int
        {
            var loc1=AcupointData.acupointInfo.roots;
            return loc1[arg1];
        }

        public static setRootLevel(arg1: int, arg2: int): void
        {
            var loc1=AcupointData.acupointInfo.roots;
            loc1[arg1] = arg2;
            return;
        }

        public static getSavvyLevel(arg1: int): int
        {
            var loc1=AcupointData.acupointInfo.savvys;
            return loc1[arg1];
        }

        public static setSavvyLevel(arg1: int, arg2: int): void
        {
            var loc1=AcupointData.acupointInfo.savvys;
            loc1[arg1] = arg2;
            return;
        }

        public static /* var */acupointInfo: SAcupointInfo;

        /* internal */ static /* var */secTimer: SecTimer;

        /* internal */ static /* var */leftTime: int;

        /* internal */ static /* var */savvyRate: SSavvyRate;

        /* internal */ static /* var */totalTime: number;

        public static /* var */topLevel: int=28;

        public static /* var */selectedStep: int=1;

        public static /* var */curRootTarget: int;

        public static /* var */maxRoot: int=130;
    }
